package com.adou.d2;

import java.util.Random;
import java.util.Scanner;

public class RandDemo2 {
    public static void main(String[] args) {
        // 1.生成幸运号
        Random r = new Random();
        int luckNum = r.nextInt(100)+1;

        // 2.定义一个死循环
        while(true) {
            System.out.print("请输入您猜测的数据：");
            Scanner sc = new Scanner(System.in);
            int guessNum = sc.nextInt();

            //
            if(guessNum > luckNum) {
                System.out.println("你猜测数字过大");
            } else if(guessNum < luckNum) {
                System.out.println("你猜测数字过小");
            } else {
                System.out.println("！！！恭喜你中奖了，" + guessNum);
                break;
            }

        }

    }
}
